package com.ccb.sc.common.modules.member.service;

import com.ccb.sc.github.yydzxz.common.http.impl.OkHttpClientByteDanceHttpClient;
import com.ccb.sc.github.yydzxz.common.redis.IByteDanceRedisOps;
//psl import com.ccb.sc.github.yydzxz.common.redis.RedisTemplatesByteDanceRedisOps;
import com.ccb.sc.github.yydzxz.miniprogram.api.IByteDanceMiniProgramService;
import com.ccb.sc.github.yydzxz.miniprogram.api.impl.ByteDanceMiniProgramInRedisConfigStorage;
import com.ccb.sc.github.yydzxz.miniprogram.api.impl.ByteDanceMiniProgramServiceImpl;
import com.ccb.sc.common.modules.setting.service.ISettingsService;
import com.ccb.sc.common.modules.setting.vo.ByteDanceMaSettingBo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

/**
 * @author ken
 * @version 1.0
 * @date 2022-07-29
 */
@Service
public class ByteDanceMaService {

    private ISettingsService settingsService;

    private StringRedisTemplate stringRedisTemplate;

    private ByteDanceMiniProgramInRedisConfigStorage maConfig() {
//        ByteDanceMaSettingBo settings = settingsService.getSettings(ByteDanceMaSettingBo.class);
//        IByteDanceRedisOps wxRedisOps = new RedisTemplatesByteDanceRedisOps(stringRedisTemplate);
//        ByteDanceMiniProgramInRedisConfigStorage config = new ByteDanceMiniProgramInRedisConfigStorage(wxRedisOps, "app:bytedance");
//        config.addMiniProgramInfo(settings.getAppid(), settings.getSecret());
//        return config;
        return null;
    }

    public IByteDanceMiniProgramService getByteDanceMaService() {
        return new ByteDanceMiniProgramServiceImpl(new OkHttpClientByteDanceHttpClient(), maConfig());
    }


    @Autowired
    @Lazy
    public void setSettingsService(ISettingsService settingsService) {
        this.settingsService = settingsService;
    }

    @Autowired
    @Lazy
    public void setStringRedisTemplate(StringRedisTemplate stringRedisTemplate) {
        this.stringRedisTemplate = stringRedisTemplate;
    }
}
